<template>
    <el-dialog v-model="dialogVisible" title="登录" width="700" :before-close="handleClose" center>
        <el-form :model="form" label-width="auto" style="max-width: 600px">
            <el-form-item label="账号/手机号">
                <el-input v-model="form.phone" placeholder="请输入账号" />
            </el-form-item>
            <el-form-item label="密码">
                <el-input v-model="form.password" placeholder="请输入密码" />
            </el-form-item>
            <el-form-item label="验证码" v-if="loginType != 1">
                <el-input v-model="form.code" placeholder="请输入验证码" style="width: 400px;" /> <el-button type="primary"
                    style="margin-left: 10px;">获取验证码</el-button>
            </el-form-item>
        </el-form>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="handleClose">取消</el-button>
                <el-button type="primary" @click="login" v-if="loginType == 1">
                    登录
                </el-button>
                <el-button type="primary" @click="login" v-else>
                    注册
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>

<script lang="ts" setup>
import { reactive, defineProps,computed,defineEmits } from 'vue'
import { useRouter } from 'vue-router';
const form = reactive({
    phone: '',
    password: '',
    code: '',
})
let emit=defineEmits(['cancel'])
let props = defineProps(['dialogVisible', 'loginType'])
const dialogVisible = computed(() => props.dialogVisible);
const loginType = computed(() => props.loginType);
let router = useRouter()



const handleClose = () => {
    emit('cancel','')
}
let login = () => {
    router.push('/myIndex')

}
</script>